import { Provide, Body, Inject, Post, Query, Get } from '@midwayjs/decorator';
import { CoolController, BaseController } from '@cool-midway/core';
import { DoupiaopiaoOrderService } from '../../service/order';
import { DoupiaopiaoOrderEntity } from '../../entity/order';

/**
 * 订单相关接口
 */
@Provide()
@CoolController({
  api: [],
  entity: DoupiaopiaoOrderEntity,
  service: DoupiaopiaoOrderService,
})
export class DoupiaopiaoAppOrderController extends BaseController {
  @Inject()
  doupiaopiaoOrderService: DoupiaopiaoOrderService;

  /**
   * 创建订单
   */
  @Post('/create', { summary: '创建订单' })
  async createOrder(@Body() body) {
    const res = await this.doupiaopiaoOrderService.createOrder(body);
    return this.ok(res);
  }

  @Post('/createTb', { summary: '淘宝创建订单' })
  async createOrderByTb(@Body() body) {
    const res = await this.doupiaopiaoOrderService.createdOrderByTb(body);
    return this.ok(res);
  }
  /**
   * 查询订单详情
   */
  @Get('/detail', { summary: '查询订单详情' })
  async getDetail(@Query('id') id: number) {
    const res = await this.doupiaopiaoOrderService.getDetail(id);
    return this.ok(res);
  }

  @Get('/checkOrder', { summary: '查询当前用户是否有空订单信息' })
  async checkOrderStatus(@Query() query) {
    const res = await this.doupiaopiaoOrderService.checkOrder(query);
    return this.ok(res);
  }
  @Get('/delCheckOrder', { summary: '删除当前的空订单' })
  async checkOrderByDel(@Query() query) {
    const res = await this.doupiaopiaoOrderService.delCheckOrder(query);
    return this.ok(res);
  }
  @Get('/verifiCation', { summary: '核销当前的票码' })
  async goVerifiCation(@Query() query){
    const res = await this.doupiaopiaoOrderService.verifiCation(query);
    return this.ok(res);
  }
  /**
   * 查询订单列表
   */
  @Get('/list', { summary: '查询订单列表' })
  async getList(@Query() query) {
    const res = await this.doupiaopiaoOrderService.getList(query);
    return this.ok(res);
  }
  @Get('/pay', { summary: '确定下单' })
  async pagMent(@Query() query) {
    const res = await this.doupiaopiaoOrderService.payMoney(query);
    return this.ok(res);
  }

  @Get('/voteDetail', { summary: '获取当前支付订单的票数' })
  async getVoteDetail(@Query() query) {
    const res = await this.doupiaopiaoOrderService.getVoteDetail(query);
    return this.ok(res);
  }
  //支付回调
  // @Post('/payCallBack', { summary: '支付回掉接口' })
  // async payCallBack(@Body() body) {
  //   const res = await this.doupiaopiaoOrderService.payCallBack(body);
  //   return this.ok(res);
  // }
}
